package com.melon.shiro;


import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.TemplateException;


import lombok.extern.log4j.Log4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
 * Created by zhiqi.shao on 2017/4/14.
 */
@Log4j
@Configuration
public class ShiroTagFreeMarkerConfigurer extends FreeMarkerConfigurer {

    @PostConstruct
    public void init(){
        this.setTemplateLoaderPath("classpath:/templates/");
    }

    @Override
    public void afterPropertiesSet() throws IOException, TemplateException {
        super.afterPropertiesSet();
        this.getConfiguration().setSharedVariable("shiro", new ShiroTags());
        this.getConfiguration().setNumberFormat("#");
    }
}
